import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/home/home.vue'
import Index from '../views/index/index.vue'
import Class from '../views/class/class.vue'
import Grade from '../views/grade/grade.vue'
import Another2 from '../views/another2/another2.vue'
const hash = createWebHashHistory()

const router = createRouter({
  // history: createWebHistory(import.meta.env.BASE_URL),
  history: hash,
  routes: [
    {
      path: '/',
      component: Home,
      redirect: '/index',
      children: [
        { path: '/index', component: Index }
      ]
    },
    {
      path: '/class',
      component: Class,
      redirect: '/grade',
      children: [
        { path: '/grade', component: Grade },
        { path: '/another2', component: Another2 }
      ]
    }
  ],
  scrollBehavior(to, from, savedPosition) {
    // 始终滚动到顶部
    return { top: 0 }
  },
})

export default router
